<html>
<head>
<script>
var urls = [
    "file:///does not exist oh noes/test.mp4",
    "../LayoutTests/media/content/test-25fps.mp4"
];
var kickoffFunctions = [
    "load",
    "play"
];

var mediaElementHolder = [];

function releaseAndAddMediaElements() {
    for (var i = 0; i < mediaElementHolder.length; ++i)
        mediaElementHolder[i].src = "";
    mediaElementHolder = [];

    for (var i = 0; i < 5; ++i) {
        for (var url in urls) {
            for (var kickoffFunction in kickoffFunctions) {
                var a = document.createElement('video');
                a.controls = "controls";
                a.src = urls[url];
                eval("a." + kickoffFunctions[kickoffFunction] + "();");
                mediaElementHolder.push(a);
            }
        }
    }
}
</script>
</head>
<body onload="setInterval('releaseAndAddMediaElements()', 100)">
    Test that media players aren't leaked on error.
    Load this page and verify the number of threads used by the browser doesn't
    seem unreasonable (e.g. chrome uses 4-5 threads per video tag so staying
    under 100 threads is "success", since this instantiates 20 &lt;video&gt; elements).
</body>
</html>
